import axios from 'axios'
import { Toast } from 'vant'
const defaults = {
  baseURL: process.env.API_ROOT
}

Object.assign(axios.defaults, defaults)

export const httpPost = (url, data, callBack) => {
  axios.get(url, data).then(function (response) {
    let data = response.data
    if (data.code === 1) {
      callBack(data.data)
    } else {
      Toast(data.msg)
    }
  }).catch(function (error) {
    console.log(error)
  })
}
export const httpGet = (url, callBack) => {
  axios.get(url).then(function (response) {
    let data = response.data
    if (data.code === 1) {
      callBack(data.data)
    } else {
      Toast(data.msg)
    }
  }).catch(function (error) {
    console.log(error)
  })
}
